package com.ado.bazinga.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.ado.bazinga.core.dal.entity.Order;
import com.ado.bazinga.core.manager.OrderManager;
import com.ado.bazinga.core.service.OrderService;

/**
 *@author adonais
 *@date 2020年3月23日
 *@description OrderServiceImpl.java
 **/
@Service(value = "orderService")
public class OrderServiceImpl implements OrderService {

	@Autowired
	@Qualifier(value = "orderManager")
	private OrderManager orderManager ;

	@Override
	public List<Order> getOrders(String userId) {
		List<Order> orders = orderManager.getOrders(Integer.valueOf(userId)) ;
		return orders;
	}

	@Override
	public boolean createOrder(Order order) {
		boolean flag = orderManager.insert(order) ;
		return flag;
	}

	@Override
	public boolean deleteOrder(int orderId) {
		boolean flag = orderManager.deleteById(orderId);
		return flag;
	}

	@Override
	public List<Order> getAllOrders() {
		List<Order> orders = orderManager.getAllOrders() ;
		return orders;
	}

	@Override
	public Order findOrderById(String orderId) {
		return orderManager.getById(Integer.valueOf(orderId));
	}

}
